package com.hai.server;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.system.Os;
import android.util.Log;

public class ServerService extends Service {
    private static final String TAG = "ServiceService";
    IMyAidlInterface.Stub binder = new IMyAidlInterface.Stub() {

        @Override
        public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException {
            Log.d(TAG, "basicTypes() called with: anInt = [" + anInt + "], aLong = [" + aLong + "], aBoolean = [" + aBoolean + "], aFloat = [" + aFloat + "], aDouble = [" + aDouble + "], aString = [" + aString + "]");
        }

        @Override
        public int getPid() throws RemoteException {
            SystemClock.sleep(2000);
            Log.d(TAG, "getpid: " + Os.getpid());
            return Os.getpid();
        }

        @Override
        public void getThreadId() throws RemoteException {
            SystemClock.sleep(2000);
            Log.d(TAG, "getthreadId: " + Thread.currentThread().getId());
        }
    };

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate: ");
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "onBind() called with: intent = [" + intent + "]");
        return binder;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.d(TAG, "onUnbind() called with: intent = [" + intent + "]");
        return super.onUnbind(intent);
    }
}